package com.elinkway.infinitemovies.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.elinkway.infinitemovies.utils.FileUtils;
import com.le123.ysdq.BuildConfig;
import com.le123.ysdq.R;
import com.umeng.analytics.MobclickAgent;

public class AboutUsActivity extends BaseSecondaryActivity {
	public static final String TAG = "AboutUsActivity";

	private long uploadTime = 0;

	TextView name;
	ImageView mAboutUsIcon;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		super.setActionBarActivityClassName(TAG);
		setContentView(R.layout.activity_about_us);
		name = (TextView) findViewById(R.id.about_us_text);
		mAboutUsIcon = (ImageView) findViewById(R.id.img_about_us_logo);
		mAboutUsIcon.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				doubleClickUpload();
			}
		});
		mAboutUsIcon.setOnLongClickListener(new View.OnLongClickListener() {
			@Override
			public boolean onLongClick(View view) {
				MyHiddenActivity.launch(AboutUsActivity.this);
				return true;
			}
		});
		name.setText(getString(R.string.text_about_us, BuildConfig.VERSION_NAME));
		initActionBar();
		//首发logo
		FirstReleaseActivityHelper startHelper = FirstReleaseActivityHelper.getInstance();
		startHelper.setActivity(this);
	}

	@Override
	protected void initActionBar(){
		super.initActionBar();
		mTitleTv.setText("关于我们");
	}


	public static void launch(Activity activity) {
		Intent intent = new Intent(activity, AboutUsActivity.class);
		activity.startActivity(intent);
	}

	@Override
	protected void onPause() {
		super.onPause();
		MobclickAgent.onPause(this);
	}

	@Override
	protected void onResume() {
		super.onResume();
		MobclickAgent.onResume(this);
	}

	public void doubleClickUpload(){
		if((System.currentTimeMillis() - uploadTime) > 2000){
			//大于2秒，不算双击，不上报
//			Toast.makeText(getApplicationContext(), "大于两秒",
//					Toast.LENGTH_SHORT).show();
			uploadTime = System.currentTimeMillis();
		}else{
			uploadTime = 0;
			FileUtils.uploadAppLog();
		}
	}

}
